home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / glibc108.zip / glibc108 / stdio / bug4.c < prev    next >
C/C++ Source or Header  |  1993-03-17  |  877b  |  51 lines

  1. #ifdef _LIBC
  2. #include <ansidecl.h>
  3. #endif
  4. #include <stdio.h>
  5. #include <unistd.h>
  6. #include <string.h>
  7.  
  8. int stdio_block_read = 1, stdio_block_write = 1;
  9.  
  10. int
  11. DEFUN(main, (argc, argv),
  12.       int argc AND char **argv)
  13. {
  14.   FILE *f;
  15.   int i;
  16.   char buffer[31];
  17.  
  18.   while ((i = getopt (argc, argv, "rw")) != EOF)
  19.     switch (i)
  20.       {
  21.       case 'r':
  22.     stdio_block_read = 0;
  23.     break;
  24.       case 'w':
  25.     stdio_block_write = 0;
  26.     break;
  27.       }
  28.  
  29.   f = fopen("bugtest", "w+");
  30.   for (i=0; i<9000; i++) {
  31.     putc('x', f);
  32.   }
  33.   fseek(f, 8180L, 0);
  34.   fwrite("Where does this text come from?", 1, 31, f);
  35.   fseek(f, 8180L, 0);
  36.   fread(buffer, 1, 31, f);
  37.   fwrite(buffer, 1, 31, stdout);
  38.   fclose(f);
  39.  
  40.   if (!memcmp (buffer, "Where does this text come from?", 31))
  41.     {
  42.       puts ("\nTest succeeded.");
  43.       return 0;
  44.     }
  45.   else
  46.     {
  47.       puts ("\nTest FAILED!");
  48.       return 1;
  49.     }
  50. }
  51.